<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateWechatUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wechat_users', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('agent_id')->nullable()->unique()->comment('代理商 ID');
            $table->char('openid', 64)->unique()->default('')->comment('微信 openid');
            $table->string('nickname')->default('')->comment('用户昵称');
            $table->char('sex')->default('')->comment('用户性别');
            $table->string('province')->default('')->comment('用户个人资料填写的省份');
            $table->string('city')->default('')->comment('用户个人资料填写的城市');
            $table->string('country')->default('')->comment('国家');
            $table->string('headimgurl')->default('')->comment('头像');
            $table->json('privilege')->nullable()->comment('用户特权信息');
            $table->string('unionid')->default('')->comment('只有在用户将公众号绑定到微信开放平台帐号后，才会出现该字段。');
            $table->timestamp('receive_last_message')->nullable()->index()->comment('接收最后一条信息的时间');
            $table->timestamp('sent_last_remind_message')->nullable()->index()->comment('发送最后一条提醒(签到)信息的时间');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wechat_users');
    }
}
